<?php
session_start();
?>
<?php
if(isset($_SESSION['User_e']) && $_SESSION['User_l'] > 0)
{
?>
<?php
?>
<title>Quản Lý Thành Viên</title>
 <meta charset="UTF-8">
<table align='center' width='450' border='1'>
<tr>
<td>STT</td>
<td>Username</td>
<td>Level</td>
<td>Edit</td>
<td>Del</td>
</tr>
<?php
 // tại đây thực thi các hoạt động khi đăng nhập thành công.<?php
    $baitren_mottrang = 5;
    $conn=mysql_connect("localhost","root","") or die("can't connect this database");
    mysql_select_db("demo",$conn);
    if (!@$_GET['page']) {
        $page = 0;
    } 
    else {
        /* @var $_GET type */
        $page = @$_GET['page'];
    }
    $sql="select * from members order by id DESC";
    $sodu_lieu = mysql_num_rows(mysql_query($sql)) or die(mysql_error());
    $sotrang = $sodu_lieu/$baitren_mottrang;
    $huuha = $page * $baitren_mottrang;
    
    $sql2 = "SELECT * FROM members LIMIT $huuha,$baitren_mottrang ";
    $result = mysql_query($sql2) or die(mysql_error());
    $query=mysql_query($sql);
    if(mysql_num_rows($query) == "")
    {
        echo "<tr><td colspan='5' align='center'>Chua co username nao</td></tr>";
    }
    else 
    {
        $stt=0;
        while($row=mysql_fetch_array($result))
        {
            $stt++;
            echo "<tr>";
            echo "<td>$stt</td>";
            echo "<td>$row[email]</td>";
            if($row['admin'] == "0")
            {
                echo "<td>Member</td>";
            }
            else if ($row['admin'] == "1")
            {   
                echo "<td>Admin</td>";
            }
            else 
            {
                echo "<td>Super Admin</td>";
            }
            echo "<td><a href='edit_user.php?userid=$row[email]'>Edit</a></td>";
            echo "<td><a href='del_user.php?userid=$row[email]'>Del</a></td>";
            echo "</tr>";
            
        }      
        

    }
}
else
{
 header("location: index.php");
 exit();
}
?>
</table>
<?php
for ($page = 0; $page < $sotrang; $page ++) { 
            
            echo "<li><a href='manager_user.php?page={$page}'> {$page} </a></li>";                                            
}
?>
 <div class="Post" style="margin-top: 10px;float: left; "><li><a href="createpost.php"> Đăng Truyện Mới </a></li></div>
 <div class="Post" style="margin-top: 10px;float: left; "><li><a href="index.php"> Trang Chủ </a></li></div>
 
<style>
    menu{float: right;margin-left: 400px;border: 2px;}
    li{float:right; margin-top: 10px; border: solid 1px gray;border-radius: 4px;}
    a{padding: 5px;text-decoration: none}
    span{display:inline-block; padding: 0px 3px; background: blue; color:white; }
</style>


